home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 May / SGI IRIX 6.5 Complementary Applications 2004 May.iso / dist / OpenOffice.idb / usr / OpenOffice / help / en / sbasic.jar / text / sbasic / common / 00000004.xml < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-24  |  11.8 KB  |  159 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Events on Objects</title><meta name="filename" content="text/sbasic/common/00000004"/><meta name="language" content="en-US"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         table.Tabelle2{
  5.                 }
  6.         span.Tabelle2A{
  7.                 width:3.413cm;}
  8.         span.Tabelle2B{
  9.                 width:14.584cm;}
  10.         td.Tabelle2A1{
  11.                 }
  12.         td.Tabelle2B1{
  13.                 border-width:0.002cm; border-style:solid; border-color:#000000;}
  14.         td.Tabelle2A2{
  15.                 }
  16.         td.Tabelle2B2{
  17.                 }
  18.         table.Tabelle1{
  19.                 }
  20.         span.Tabelle1A{
  21.                 width:0.794cm;}
  22.         span.Tabelle1B{
  23.                 width:17.203cm;}
  24.         td.Tabelle1A1{
  25.                 }
  26.         p.P1{
  27.                 }
  28.         p.P2{
  29.                 }
  30.         p.P3{
  31.                 }
  32.         span.T1{
  33.                 font-weight:bold;}
  34.         </style></head><body>
  35.    
  36.    
  37.    <p class="P1"/>
  38.    <p class="Head1"><help:key-word value="Events on Objects" tag="kw66462_1" xmlns:help="http://openoffice.org/2000/help"/>Events on Objects</p>
  39.    <p class="Paragraph">When you insert an object in a document, you can assign a macro to some predefined events. This macro will then be executed when the event happens. In <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname>, you can get this function by using the corresponding object dialog. That means if the object is a frame, you should use the <span class="T1">Frame</span> <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>dialog, and if it is a graphic, please use the <span class="T1">Graphic</span> dialog, etc. Depending on the object selected, a list of all events defined for the current object will be found either on the <help:link Id="67665" xmlns:help="http://openoffice.org/2000/help"><span class="T1">Macro</span></help:link> tab page of the Object dialog, or in the <span class="T1">Assign Macro</span> dialog.</p>
  40.    <p class="Paragraph">The macro is generally formulated in a SUB. The default composition of this SUB is as follows:</p>
  41.    <p class="Paragraph">Sub EventRoutine()</p>
  42.    <p class="Paragraph">[command lines]</p>
  43.    <p class="Paragraph">End Sub</p>
  44.    <p class="Paragraph">The SUB EventRoutine should then be linked to an event. It will be initiated as soon as the event occurs.</p>
  45.    <p class="Head2"><help:key-word value="Linking special Events to frames" tag="kw66462_2" xmlns:help="http://openoffice.org/2000/help"/>Linking special Events to frames</p>
  46.    <p class="Paragraph">If you insert a frame in a text document, you will not only find the general events also used with other objects, e.g., to select an object etc., but also some special events, which can be used to change or move the frame. These events can be processed in different ways. You can link them to a Basic FUNCTION, where it can be decided whether the event is to be processed by <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Writer or by the FUNCTION itself.</p>
  47.    <p class="Paragraph">Some parameters will be set for the FUNCTION. The first parameter is always the name of the frame. An integer value can be used to determine how the event should be processed. The following values are possible:</p>
  48.    <p class="Paragraph">0: The event will be processed by <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Writer.</p>
  49.    <p class="Paragraph">1: The event will be processed by the FUNCTION.</p>
  50.    <p class="Paragraph">Use the return value "1", for example, to define that no character should be entered in the frame after a specified keyboard input, or to determine the action to be executed when using certain keys. The following examples illustrate this:</p>
  51.    <p class="Paragraph">If the FUNCTION KeyAlpha is linked to the event "Input of alphanumeric characters", all special characters entered by the user will be replaced by custom characters.</p>
  52.    <p class="PropText">Function KeyAlpha( sFrame as String, iCode as Integer ) as Integer</p>
  53.    <p class="PropText">Dim sChange as String</p>
  54.    <p class="PropText">iCode = &h00ff AND iCode REM only the lowermost byte correpsonds a key</p>
  55.    <p class="PropText"/>
  56.    <p class="PropText">REM a short transformation table</p>
  57.    <p class="PropText">Select Case iCode</p>
  58.    <p class="PropText">Case ASC("├╢"): sChange = "oe"</p>
  59.    <p class="PropText">Case ASC("├ƒ"): sChange = "ss"</p>
  60.    <p class="PropText">Case ASC("├╝"): sChange = "ue"</p>
  61.    <p class="PropText">Case ASC("├ñ"): sChange = "ae"</p>
  62.    <p class="PropText">End Select</p>
  63.    <p class="PropText"/>
  64.    <p class="PropText">If sChange = "" Then</p>
  65.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>KeyAlpha = 0 REM Character does not have to be replaced. <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Writer displays it</p>
  66.    <p class="PropText">Else</p>
  67.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>rem use the changed string</p>
  68.    <p class="PropText">KeyAlpha = 1 REM replace input</p>
  69.    <p class="PropText">End If</p>
  70.    <p class="PropText"/>
  71.    <p class="PropText">End Function</p>
  72.    <p class="PropText"/>
  73.    <p class="Paragraph">The next example demonstrates how formatting can be assigned directly via keyboard. If the FUNCTION KeyNoAlpha is linked to the event "Input of non-alphanumeric characters", predefined formatting will directly be assigned when predetermined shortcut keys are used.</p>
  74.    <p class="PropText">Function KeyNoAlpha( sFrame as String, iKey as Integer ) as Integer</p>
  75.    <p class="PropText"/>
  76.    <p class="PropText">KeyNoAlpha = 1</p>
  77.    <p class="PropText"/>
  78.    <p class="PropText">Select Case iKey</p>
  79.    <p class="PropText">Case 5382: REM (Shift)+(Del) deletes all frame contents</p>
  80.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>REM Select All</p>
  81.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>REM Delete all</p>
  82.    <p class="PropText">Case 12800: REM (Ctrl)(Shift)+(A) Aligns the frame to the center.</p>
  83.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>Rem center the frame</p>
  84.    <p class="PropText">Case 12802: REM (Ctrl)(Shift)+(C) makes the background pinkish</p>
  85.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>REM Set Background color= RGB(255,127,127)</p>
  86.    <p class="PropText"/>
  87.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>Case else REM All other keys do not have special functions; thus try to execute them using $[officename ] Writer</p>
  88.    <p class="PropText"/>
  89.    <p class="PropText">KeyNoAlpha = 0</p>
  90.    <p class="PropText"/>
  91.    <p class="PropText">End Select</p>
  92.    <p class="PropText"/>
  93.    <p class="PropText">End Function</p>
  94.    <p class="PropText"/>
  95.    <p class="Paragraph">The passed parameters of the FUNCTION depend of the corresponding event:</p>
  96.    <table border="1" bordercolor="#000000" cellpadding="2" cellspacing="0" page-break-inside="page-break-inside:avoid"><tr class=""><th class="Tabelle2A1" style="text-align:left;"><span class="Tabelle2A">
  97.        <p class="P2">Event</p>
  98.       </span></th><th class="Tabelle2B1" style="text-align:left;"><span class="Tabelle2B">
  99.        <p class="P2">Syntax</p>
  100.       </span></th></tr><tr class=""><td class="Tabelle2A2" style="text-align:left;"><span class="Tabelle2A">
  101.       <p class="TextInTable">Input of alphanumeric characters</p>
  102.      </span></td><td class="Tabelle2B2" style="text-align:left;"><span class="Tabelle2B">
  103.       <p class="TextInTable">FUNCTION Alpha(FrameName as String, Code as Integer) as Integer</p>
  104.      </span></td></tr><tr class=""><td class="Tabelle2A2" style="text-align:left;"><span class="Tabelle2A">
  105.       <p class="TextInTable">Input of non-alphanumeric characters</p>
  106.      </span></td><td class="Tabelle2B2" style="text-align:left;"><span class="Tabelle2B">
  107.       <p class="TextInTable">FUNCTION NotAlpha(FrameName as String, KeyCode as Integer) as Integer</p>
  108.      </span></td></tr><tr class=""><td class="Tabelle2A2" style="text-align:left;"><span class="Tabelle2A">
  109.       <p class="TextInTable">Resize frame</p>
  110.      </span></td><td class="Tabelle2B2" style="text-align:left;"><span class="Tabelle2B">
  111.       <p class="TextInTable">FUNCTION FrameSize(FrameName as String, HandleID as Integer, X as Long, Y as Long) as Integer</p>
  112.      </span></td></tr><tr class=""><td class="Tabelle2A2" style="text-align:left;"><span class="Tabelle2A">
  113.       <p class="TextInTable">Move frame</p>
  114.      </span></td><td class="Tabelle2B2" style="text-align:left;"><span class="Tabelle2B">
  115.       <p class="TextInTable">FUNCTION FramePosition(FrameName as String, X as Long, Y as Long) as Integer</p>
  116.      </span></td></tr></table>
  117.    <p class="Paragraph"/>
  118.    <p class="P3">Parameter</p>
  119.    <p class="Paragraph">FrameName: Name of the frame, in which the respective event occurs.</p>
  120.    <p class="Paragraph">Code: The ASCII code for the character to be entered.</p>
  121.    <p class="Paragraph">KeyCode: A <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> specific code for the nonprinting character to be entered.</p>
  122.    <p class="Paragraph">HandleID: The ID number of the point, at which the frame size will be changed. The following values are possible:</p>
  123.    <table><tr class=""><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  124.        <p class="TextInTable">1</p>
  125.       </span></th><th style="text-align:left;"><span class="Tabelle1B">
  126.        <p class="TextInTable">Top Left</p>
  127.       </span></th></tr><tr class=""><td class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  128.       <p class="TextInTable">2</p>
  129.      </span></td><td style="text-align:left;"><span class="Tabelle1B">
  130.       <p class="TextInTable">Top center</p>
  131.      </span></td></tr><tr class=""><td class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  132.       <p class="TextInTable">3</p>
  133.      </span></td><td style="text-align:left;"><span class="Tabelle1B">
  134.       <p class="TextInTable">Top right</p>
  135.      </span></td></tr><tr class=""><td class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  136.       <p class="TextInTable">4</p>
  137.      </span></td><td style="text-align:left;"><span class="Tabelle1B">
  138.       <p class="TextInTable">Middle, left</p>
  139.      </span></td></tr><tr class=""><td class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  140.       <p class="TextInTable">5</p>
  141.      </span></td><td style="text-align:left;"><span class="Tabelle1B">
  142.       <p class="TextInTable">Middle, right</p>
  143.      </span></td></tr><tr class=""><td class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  144.       <p class="TextInTable">6</p>
  145.      </span></td><td style="text-align:left;"><span class="Tabelle1B">
  146.       <p class="TextInTable">Bottom, left</p>
  147.      </span></td></tr><tr class=""><td class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  148.       <p class="TextInTable">7</p>
  149.      </span></td><td style="text-align:left;"><span class="Tabelle1B">
  150.       <p class="TextInTable">Bottom, middle</p>
  151.      </span></td></tr><tr class=""><td class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  152.       <p class="TextInTable">8</p>
  153.      </span></td><td style="text-align:left;"><span class="Tabelle1B">
  154.       <p class="TextInTable">Bottom, right</p>
  155.      </span></td></tr></table>
  156.    <p class="Paragraph"/>
  157.    <p class="Paragraph">X: X difference to the starting point in twips.</p>
  158.    <p class="Paragraph">Y: Y difference to the starting point in twips.</p>
  159.   </body></html>